﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentData;
using Framework.Data;

namespace Framework.Core
{
    internal class RulePageDataAccess : BaseDataAccess
    {
        internal List<RulePage> GetRulePages()
        {
            var sql = "SELECT [Rule_Page].[sPageName], [Rule_Page].[sRuleID], [Rule_Page].[sControlName] FROM [Rule_Page] ORDER BY [Rule_Page].[sRuleID]";

            using (var context = DataHelper.GetBaseDbContext())
            {
                var rulePages =
                    context.Sql(sql).QueryMany<RulePage>(delegate(RulePage map, IDataReader reader)
                    {
                        map.RuleID = reader.GetString("sRuleID");
                        map.PageName = reader.GetString("sPageName");
                        map.ControlName = reader.GetString("sControlName");
                        //TODO:更多字段
                    });
                return rulePages;
            }
        }
    }
}
